aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/redeem/[redeemcode]/+page.server.js
blob: 4f685d686fd3e69490b1be2d55b5b8442f48797c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { error, redirect } from '@sveltejs/kit';
import { auth, post } from '$lib/utils';

export async function load({ cookies, locals, params }) {
	let { user } = locals;

	if (user) {
		try {
			await post('/redeem', params, auth(cookies));
		} catch (e) {
			throw redirect(307, '/');
		}
		throw redirect(307, `/${user.username}/payments`);
	}

	throw redirect(307, '/login');
}